package cn.iocoder.yudao.module.wms.dal.mysql.stock;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.wms.dal.dataobject.stock.StockDO;
import cn.iocoder.yudao.module.wms.dal.dataobject.stock.StockLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wms.controller.admin.stock.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 存货管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface StockMapper extends BaseMapperX<StockDO> {

    default PageResult<StockDO> selectPage(StockPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StockDO>()
                .betweenIfPresent(StockDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(StockDO::getInventoryId, reqVO.getInventoryId())
                .eqIfPresent(StockDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(StockDO::getLocationId, reqVO.getLocationId())
                .likeIfPresent(StockDO::getBatchCode, reqVO.getBatchCode())
                .orderByDesc(StockDO::getId));
    }

    StockDO findByInventoryId(StockDO stockDO);
    StockRespVO getStock(Integer id);
    List<StockLogDO> selectListByInventoryId(StockLogDO stockLogDO);
    List<StockLogRespVO> findUsedAll();
    List<StockRespVO> findSaleListByInventoryId(StockSaleSelectVO stockSaleSelectVO);
    StockLogRespVO findStockLogById(Integer id);

    void updateStockLog(StockLogRespVO stockLogRespVO);
    int findBatchCodeDuplicate(String batchCode);
    List<StockRespVO>viewStock(StockRespVO stockRespVO);
    void deleteByStock(StockDO stockDO);
    void restoreByStock(StockDO stockDO);


}